package com.outfoodmanage.controller;

import java.util.List;

import com.outfoodmanage.domain.FoodRule;
import com.outfoodmanage.service.IFoodRuleService;
import com.rys.common.utils.Search;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 规则Controller
 *
 * @author ruoyi
 * @date 2025-01-23
 */
@Controller
@RequestMapping("/system/rule")
public class FoodRuleController extends BaseController
{
    private String prefix = "system/rule";

    @Autowired
    private IFoodRuleService foodRuleService;

    @RequiresPermissions("system:rule:view")
    @GetMapping()
    public String rule()
    {
        return prefix + "/rule";
    }

    /**
     * 查询规则列表
     */
    @RequiresPermissions("system:rule:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(FoodRule foodRule)
    {
        startPage();
        List<FoodRule> list = foodRuleService.getList(new Search(),"id desc");
        return getDataTable(list);
    }
//
//    /**
//     * 导出规则列表
//     */
//    @RequiresPermissions("system:rule:export")
//    @Log(title = "规则", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    @ResponseBody
//    public AjaxResult export(FoodRule foodRule)
//    {
//        List<FoodRule> list = foodRuleService.selectFoodRuleList(foodRule);
//        ExcelUtil<FoodRule> util = new ExcelUtil<FoodRule>(FoodRule.class);
//        return util.exportExcel(list, "rule");
//    }
//
//    /**
//     * 新增规则
//     */
//    @GetMapping("/add")
//    public String add()
//    {
//        return prefix + "/add";
//    }
//
//    /**
//     * 新增保存规则
//     */
//    @RequiresPermissions("system:rule:add")
//    @Log(title = "规则", businessType = BusinessType.INSERT)
//    @PostMapping("/add")
//    @ResponseBody
//    public AjaxResult addSave(FoodRule foodRule)
//    {
//        return toAjax(foodRuleService.insertFoodRule(foodRule));
//    }
//
//    /**
//     * 修改规则
//     */
//    @GetMapping("/edit/{id}")
//    public String edit(@PathVariable("id") Long id, ModelMap mmap)
//    {
//        FoodRule foodRule = foodRuleService.selectFoodRuleById(id);
//        mmap.put("foodRule", foodRule);
//        return prefix + "/edit";
//    }
//
//    /**
//     * 修改保存规则
//     */
//    @RequiresPermissions("system:rule:edit")
//    @Log(title = "规则", businessType = BusinessType.UPDATE)
//    @PostMapping("/edit")
//    @ResponseBody
//    public AjaxResult editSave(FoodRule foodRule)
//    {
//        return toAjax(foodRuleService.updateFoodRule(foodRule));
//    }
//
//    /**
//     * 删除规则
//     */
//    @RequiresPermissions("system:rule:remove")
//    @Log(title = "规则", businessType = BusinessType.DELETE)
//    @PostMapping( "/remove")
//    @ResponseBody
//    public AjaxResult remove(String ids)
//    {
//        return toAjax(foodRuleService.deleteFoodRuleByIds(ids));
//    }
}